﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using PMSGSC.DAL;

namespace PMSGSC.App
{
    public partial class frmReportWorkOrder : DevExpress.XtraEditors.XtraForm
    {
        private List<WorkOrder> dataSource = new List<WorkOrder>();
        public frmReportWorkOrder(List<WorkOrder> dataSource)
        {
            InitializeComponent();
            rpWorkOrders rp = new rpWorkOrders(dataSource, cbbSort.SelectedIndex);
            rp.PrintingSystem.ClearContent();
            rp.CreateDocument();
            printControl1.PrintingSystem = rp.PrintingSystem;
            this.dataSource = dataSource;
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (0 == cbbFormat.SelectedIndex)
            {
                rpWorkOrders rp = new rpWorkOrders(this.dataSource, cbbSort.SelectedIndex);
                rp.PrintingSystem.ClearContent();
                rp.CreateDocument();
                printControl1.PrintingSystem = rp.PrintingSystem;
            }
            else
            {
                rpWorkOrderDetails rpd = new rpWorkOrderDetails(this.dataSource, cbbSort.SelectedIndex);
                rpd.PrintingSystem.ClearContent();
                rpd.CreateDocument();
                printControl1.PrintingSystem = rpd.PrintingSystem;
            }
        }

        private void frmReportWork_SizeChanged(object sender, EventArgs e)
        {
            printControl1.Height = this.Size.Height - 80;
        }
    }
}